|
|
|
|
|
|
|
quick answer and asked permission to use his exact text in the book (without mentioning his name), which he was kind enough to grant. |
|
|
|
|
|
|
|
|
The quick answer I gave him was in the form of suggestions as to how to proceed. It did not include an example of how to use the NetAddUser function. You can, if you wish, try to figure out the answer to the question now. Or you can read on as I demonstrate the process of creating a sample puzzle. To do so, I'm going to adopt a writing style that I occasionally use in articles and that I've never seen used by any other author. |
|
|
|
|
|
|
|
|
This chapter is being written in real time. |
|
|
|
|
|
|
|
|
What does this mean? It means that I am literally writing this chapter as I work out the problem. You get to watch over my shoulder, so to speak, as I figure out how to make this function work. In order to be effective, the writing has to be honest, so you'll get to see the mistakes I make along the way as well. Note that the chapter is written in past tense in order to maintain a consistent voice, but rest assured, I'm writing the text as I write the code. |
|
|
|
|
|
|
|
|
My first step was to do a search in the Win32 SDK for the function NetAddUser. Here's where I ran into my first problem. There is no such function. So I switched to the function reference and went to the alphabetical listing of functions that begin with the word ''Net." I quickly found that the function's name was NetUserAdd. |
|
|
|
|
|
|
|
|
The Win32 SDK begins with a warning that the function will only work in a program that runs as a member of the Administrators group. Not surprising; after all, I'm talking about adding a user to the system. It's also a function that runs only on Windows NT. This is also not surprising, since Windows 95 doesn't provide much support when it comes to managing users. To test the program, you'll need to log on to a Windows NT workstation or server under an administrator account. |
|
|
|
|
|
|
|
|
The function is declared in C as follows: |
|
|
|
|
|
|
|
|
NET_API_STATUS NetUserAdd( LPWSTR servername,
DWORD level,
LPBYTE buf,
LPDWORD parm_err ); |
|
|
|
|
|
|
|
|
What could I tell from this? |
|
|
|
|
|